#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author: John
 
"""
查询四六级成绩。
"""
 
import urllib2
import urllib
import cookielib
heads = {
    "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0",
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
     "Accept-Language": "zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3",
     "Accept-Encoding": "gzip, deflate",
     "Referer": "http://cet.99sushe.com",
     "Connection": "keep-alive",
}
def get99(url, cetId, name):
    try:
        data = urllib.urlencode({"id":cetId, "name": name})
        req = urllib2.Request(url, data, heads)
        f = urllib2.urlopen(req)
        data = f.read().split(",")
        print data
        print u"姓名：", data[-2]
        print u"学校：", data[-1]
        print u"类别：", "cet-"+data[0]
        print u"总分：", data[-3]
        print u"听力：", data[1]
        print u"阅读：", data[2]
        print u"写作：", data[3]
        input()
    except Exception,e:
        raise e
 
url = "http://cet.99sushe.com/find"
cetId = raw_input("id:")
name = raw_input("name:")
get99(url, cetId, name)
